﻿using System.Collections.Generic;
using ReportWizard.DataAccess;
using ReportWizard.Helpers;
using ReportWizard.Interface;

namespace ReportWizard.Entities
{
    public class Report
    {
        public string Name { get; set; }

        public WordTemplate ReportTemplate { get; set; }

        public List<ReportImageFileList> PhotoCollection { get; set; }

        public Dictionary<IBookmark, ReportBaseObject> Fields { get; set; }

        public void SaveToArchive()
        {
            ArchiveReport ar = new ArchiveReport(Globals.CurrentUser.Id, Globals.CurrentReport.ReportTemplate.Id, Globals.CurrentReport.Name);
            ar.Insert();

            foreach (KeyValuePair<IBookmark, ReportBaseObject> field in Fields)
            {
                if (field.Value != null && field.Value.Id > 0)
                {
                    ArchiveReportBaseObject arbs = new ArchiveReportBaseObject(ar.Id, field.Value.Id);
                    arbs.Insert();
                }
            }
        }
    }
}
